<template>
    <div class="background-processor">
        <styled-uploader @success="onImageUploaded" v-if="!value"></styled-uploader>
        <image-processer @change="handleUploadUrl" :showDelete="true" :value="value" v-else></image-processer>
    </div>
</template>
<script setup lang="ts">
import { computed } from 'vue'
import ImageProcesser from './ImageProcesser.vue'
import StyledUploader from '@/components/StyledUploader.vue'
import { message } from 'ant-design-vue'

const props = defineProps({
    value: {
        type: String,
        required: true
    }
})
const emits = defineEmits(['change'])
const onImageUploaded:any =(res: UploadResp)=>{
    const {data} =res;
    message.success('上传成功')
    emits('change', data.urls[0])
}
const handleUploadUrl = (url: string)=>{
    emits('change', url)
}

</script>
<style lang="scss" scoped>

.l-image-component {
    max-width: 100%;
    position: relative !important;
}
</style>